package com.eight.cloud.payment.common.enums;


import com.eight.cloud.core.global.exception.ParameterException;
import lombok.Getter;

/**
 * @EnumName: PayType
 * @Description: 支付类型
 * @Author: TXC
 * @Date: 2024-12-27 10:45
 **/
@Getter
public enum PayChannelEnum {
    ALIPAY("alipay", "支付宝"),
    WECHAT("wechat", "微信"),
    UNION_PAY("union", "银联支付");

    private final String code;
    private final String name;

    PayChannelEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }


    public static PayChannelEnum getByCode(String code) {
        for (PayChannelEnum payChannelEnum : PayChannelEnum.values()) {
            if (payChannelEnum.getCode().equals(code)) {
                return payChannelEnum;
            }
        }
        throw new ParameterException("支付渠道不存在");
    }
}
